package com.hpin.mlxteacher.utils;

import android.content.Context;
import android.content.Intent;

import com.hpin.mlxteacher.bean.TopicBean;
import com.hpin.mlxteacher.ui.LoginActivity;

import java.util.Map;

/**
 * Created by Administrator on 2015/7/14.
 * 常量类
 */
public class Constant {

    public final static String HOST = "https://kungfuhacking.cn";
    //public final static String HOST = "https://test.healxh.cn";

    public final static String HOST_IP = HOST + ":19991";//测试环境

    public final static String WEB_ROOT = HOST_IP + "/teacher/";
    public final static String WEB_ROOT_TALK = HOST_IP + "/talk/";

    public final static String MINGLUXING_CODE = "我是明路星教师端的密码";// 电量消息

    public final static String LOGIN = "login"; //登陆url
    public final static String TALK_LOGIN = "talkLogin";//登录
    public final static String REG = "reg";   //注册
    public final static String UPDATEPWD = "updatePwd";
    public final static String MYCOLLEAGUE = "myColleague";    //通讯录
    public final static String GETCHILDINFO = "getChildInfo";  //孩子列表
    public final static String GETCHILDFAMILYINFO = "getChildFamilyInfo";  //家庭详情
    //    public final static String UPDATEFAMILYINFO = "updateChildFamilyInfo";//更新家庭信息
    public final static String SMSCODE = "smsCode";//注册
    public final static String REGISTER = "regCheck";//注册 提交验证 验证码
    public final static String FORGET = "forget";  //忘记密码url
    public final static String FORGETCHECK = "forgetCheck";//忘记密码 提交验证 验证码
    //    public final static String GETMSGLIST = "getSendMsgList"; //获得发件箱列表
//    public final static String GETRECEIVEMSGLIST = "getReceiveMsgList";    //获得收件箱列表
    public final static String SENDMSG = "sendMsg"; //发送消息
    public final static String RECEIVEPEOPLELIST = "receivePeopleList";  //学校的收件人列表
    public final static String GETCHILDERNANDWATCH = "getChildernAndWatch";   //孩子的收件人列表
    public final static String GETCHILDERN = "getChildern"; //获取孩子列表
    public final static String GETTREE = "getTree";    //获取宝宝树列表
    public final static String SENDTREE = "sendTree"; //发布宝宝树
    public final static String DELTREE = "delTree"; //删除宝宝树
    public final static String SENDCOMMENT = "sendComment"; //宝宝树发表评论
    public final static String TEACHERBINDCLASS = "teacherBindClass";//二维码接口
    //    public final static String SEARCHMSG = "searchMsg";//搜索消息
//    public final static String uploadPic = "uploadPic"; //上传图片
    public final static String CHECKDAY = "checkDay";   //更改签到状态
    public final static String CHECKLIST = "checkList";    //获取签到列表
    public final static String CHECKFORHISTORY = "checkForHistory";//签到历史月份查询
    public final static String RECORDINFO = "recordInfo";  //生活记录详情
    public final static String RECORDUPDATE = "recordUpdate";  //生活记录更新
    public final static String RECORDLIST = "recordList";   //生活记录列表
    public final static String UPDATEUSERINFO = "updateUserInfo";  //更改用户信息
    public final static String VERSION = "ver"; //获取版本信息
    public final static String MYCLASSES = "myClasses";//获取班级
    public final static String CONFIG = "mingluxing_config";
    public final static String TEACHERUNBINDCLASS = "teacherUnbindClass";//解除班级
    //    public final static String MESSAGECOUNT = "msgInfoNum";//未读消息个数, 显示的小红点
    public final static String UPLOADTOKEN = "uploadToken"; //设置照片(我的)
//    public final static String GETCHILDERN = "getChildern";//选择班级(发布)

    public final static String USERNAME = "username";
    public final static String PSW = "psw";

    public static final String NEWS = "NEWS";
    public static final String CHILD = "CHILD";
    public static final String PHOTO = "PHOTO";
    public static final String BABYTREE = "BABYTREE";
    public static final String MY = "MY";
    public static final String TYPE = "android";
    //添加的图片 + 的地址 (乱写的地址)
    public final static String ADDBITMAPPATH = "mlx/add.jpg";
    public final static String VERDATA = "ver_data_teacher"; //存储配置文件信息的key

    public static final String NODATA = "数据获取失败";
    public static final String NOMOREDATA = "没有更多数据了";
    public static final String LOADING = "加载中...";
    public static final String WAIT = "请稍后...";
    public static final String MODIFY = "修改中...";
    public static final String DATA = "更改成功!";
    public static final String COMMENTSUCCESS = "评论成功";
    public static final String COMMENTFAIL = "评论失败";
    public static final int SUCCESS = 0;// 成功
    public static final int FA_TOKEN_ERROR = 202;// 设备token错误
    private static final int FA_UNKNOW_ERROR = 1000;// 未知错误
    private static final int FA_PHONENUM_EXIST = 1001;// 电话号码已存在/注册时
    private static final int FA_MSCODE_ERROR = 1004;// 短信验证码错误
    private static final int FA_MSCODESEND_ERROR = 1005;// 短信验证码发送失败
    private static final int FA_PHONENUM_NOT_EXIST = 1002;// 电话号码不存在
    private static final int FA_AES_ERROR = 113;// 解密失败
    private static final int FA_PHONENUM_ERROR = 114;// 电话号码错误/登陆时
    private static final int FA_PASSWORD_ERROR = 1003;// 密码错误
    private static final int FA_PHNOEKEY_ERROR = 1006;// phonekey与上次登陆时不一致//TOKEN错误
    private static final int FA_TOKEN_TIMEOUT_ERROR = 1007;// TOKEN超时
    private static final int FA_VERSION_OLD = 1008;//版本落后
    private static final int FA_SN_ERROR = 1009;//SN不存在
    private static final int FA_SN_BIND_ERROR = 1010;//SN已经被绑定
    private static final int FA_BIND_ERROR_INVITATION = 1018;// 邀请码错误
    private static final int FA_BIND_ERROR = 117;// SN码错误
    private static final int FA_DEVICEID_ERROR = 201;// 设备ID错误
    private static final int FA_NO_DATA_ERROR = 203;// 数据库中无记录
    private static final int FA_DEVICECONNECT_ERROR = 204;// 设备无连接
    private static final int FA_BINDING_ALREADY = 205;// 绑定错误
    private static final int FA_DATA_FORMATE_ERROR = 3000;// 数据格式错误
    private static final int FA_DATA_ERROR = 3001;// 数据错误
    public static final int FA_RIGHT_ERROR = 9999;// 无权限
    private static final int FA_API_ERROR = 404;// 接口不存在
    private static final int UNBIND_ONLY_ONE_ERROR = 1019;// 解绑定人为唯一管理员,请提升另一人为管理员后再解绑定
    private static final int UNBIND_DELETE_ERROR = 1020;// 解绑孩子仍然绑定手表,请先解绑孩子的手表后,在解绑定孩子


    /**
     * 发送警告类型
     */
    public static final int MESSAGE = 700;// 普通消息
    public static final int BIND_MESSAGE = 701;// 绑定消息
    public static final int SAFEAREA_MESSAGE = 702;// 安全围栏消息
    public static final int BATTERY_MESSAGE = 703;// 电量消息

    public static final String phoneNum = "phoneNum";
    public static final String nickName = "nickName";
    public static final String classId = "childIds";//班级id
    public static final String className = "className";//班级名称

    public static final String imgUrl = "imgUrl";
    public static final String sex = "sex";
    public static final String birthday = "birthday";
    public static final String classGrade = "classGrade";
    public static final String id = "id";
    public static final String token = "token";
    public static final String data = "data";
    public static final String CITYNAME = "CITYNAME";
//    public static final String USERIMG = "USERIMG";//

    public final static String build = "build_teacher";  //版本配置文件

    public final static String MSG_MESSAGE = "1001001"; //消息
    public final static String MSG_UNFINISHED_WORK = "1001002"; //代办事项
    public final static String MSG_NOTIFICATION = "1001003";//通知

    //上传失败的默认头像
    public static final String IMAGE_URL_FAIL = "http://7xn7x2.com2.z0.glb.qiniucdn.com//group/2016-03-29/tx1yb3c7n4m9xzbp9hfa93df5w7us9y43tivgwlthnhbfxrn8aysijrol8uj3s5m_s";
    public final static String PHOTO_PATH = "/mlxTeacherCache";
    public final static String PHOTO_PATH_HINT = "/.mlxTeacherCache";

    public static String[] TOPICS;//

    public static Map<String, TopicBean> topicMap;//

    public static String currentContractTopic = "";//当前聊天的id

    //////////////////////       信息发送类型     ////////////////////
    public static final String MQTTMESSAGETEXT = "Text";//文本
    public static final String MQTTMESSAGEPHOTO = "Picture";//图片
    public static final String MQTTMESSAGEVOICE = "Voice";//语音
    public static final String MQTTMESSAGETODO = "Todo";//网页代办
    public static final String MQTTMESSAGENOTICE = "Notice";//通知, 创建群, 删人 加人

    public static final int EMO_PAGE_ONE = 0;
    public static final int EMO_PAGE_TWO = 1;
    public static final int EMO_PAGE_THREE = 2;

    public static final String DELETEEMO = "[delete]";

    //聊天记录表
    public static final String HISTORY_TABLE = "chatHistory";
    //订阅的主题表  和 聊天的最新的一条记录表
    public static final String TOPIC_TABLE = "topics";
    //数据库名称
    public static final String DB_NAME = "ckmqtt.db";

    public static final String SUB = "sub";
    public static final String UN_SUB = "unsub";

    /////////////////////       聊天类型        /////////////////////
    public static final int CHAT_SINGLE = 0x0;//私聊
    public static final int CHAT_GROUP = 0x1;//群聊

    public static final String START_SINGLE = "/f/";//单聊
    public static final String START_GROUP = "/g/";//群聊
    public static final String START_CHILD = "/c/";//孩子
    public static final String START_S = "/s/";//系统 显示
    public static final String START_SYSTEM = "/system/";//系统 (不显示) sub unsub

    public static final int CHAT_HISTORY_COUNT = 20;//聊天历史查询的个数

    /**
     * messagebean 字段中 operationStyle 的类型
     */
    public static final String DELETE_RECENT_HISTORY = "DELETE_RECENT_HISTORY";//删除最近聊天记录code
    public static final String OFF_GROUP = "OFF_GROUP";//退出群,删除人的code
    public static final String RECEIVE_MESSAGE = "RECEIVE_MESSAGE";//接受到新消息

    public static final String TOPIC_MAP = "TOPIC_MAP";//保存到sp中的 topicName 和 topicPic

    public static final String UPDATE_RED_COUNT = "UPDATE_RED_COUNT";//通知底部状态栏更新小红点个数

    /**
     * 新消息是否提醒 1 不提醒, 默认提醒 (默认为0)
     */
    public static final String REMAIND = "REMAIND";//1

    public static final int CREATE_GROUP = 0x121;//创建群聊
    public static final int DELETE_GROUP_NUMS = 0x122;//删除群成员
    public static final int ADD_GROUP_NUMS = 0x123;//添加群成员


    //    public final static int SUCCESS = 1000;
    public final static int E_NOSDCARD = 1001;
    public final static int E_STATE_RECODING = 1002;
    public final static int E_UNKOWN = 1003;


    public final static String MQTTNOTCONNECT = "MQTTNOTCONNECT";//mqtt未连接


    public static final int MQTT_QOS_ONE = 1;//mqtt qos


    public final static String SEARCHUSER = "searchUser"; //搜索用户
    public final static String INVITEFRIEND = "inviteFriend"; //发送好友申请
    public final static String MYCONTACTS = "myContacts"; //通讯录
    public final static String INVITEDLIST = "invitedList"; //邀请列表
    public final static String DEALINVITE = "dealInvite"; //处理好友请求
    public final static String JOINGROUP = "joinGroup"; //创建群组
    //    public final static String UPLOADGROUPPIC = "UploadGroupPic"; //上传群头像
    public final static String LEFTGROUP = "leftGroup"; //退出群聊
    public final static String GROUPLIST = "groupList"; //群聊列表
    public final static String GROUPINFO = "groupInfo"; //群信息
    public final static String GROUPSETTING = "groupSetting"; //群设置
    //    public final static String USERHISTORY = "userHistory"; //离线消息
    public final static String DELFRIEND = "delFriend"; //离线消息
    public final static String UPDATEGROUPADMIN = "updateGroupAdmin"; //修改群主
    public final static String MQTTIP = "MQTTIP"; //mqtt登录ip
    public final static String MQTTPORT = "MQTTPORT"; //mqtt登录端口
    public final static String CHILDTALKLIST = "childTalkList"; //家庭群列表


    public static final int UNLISTENER = 0;//语音未读取状态
    public static final int LISTENERED = 1;//语音读取过的状态


    public static String showErrorMsg(int code, Context ctx) {

        String errorMessage = "";

        switch (code) {

            case FA_PHONENUM_EXIST:
                errorMessage = "电话号码已存在";
                break;

            case FA_MSCODE_ERROR:
                errorMessage = "短信验证码错误";
                break;

            case FA_MSCODESEND_ERROR:
                errorMessage = "短信验证码发送失败";
                break;

            case FA_AES_ERROR:
                errorMessage = "解密失败";
                break;

            case FA_PHONENUM_ERROR:
                errorMessage = "电话号码错误";
                break;

            case FA_PASSWORD_ERROR:
                errorMessage = "密码错误";
                break;

            case FA_PHNOEKEY_ERROR:
                errorMessage = "登录超时";

//                MyApplication mApplication = (MyApplication) ctx.getApplicationContext();
//                mApplication.clearActivity();

                Intent intent = new Intent(ctx, LoginActivity.class);
                intent.putExtra("isAutoLogin", false);
//                intent.addFlags(Intent.);
                ctx.startActivity(intent);

                return errorMessage;

//                break;
            case FA_DEVICEID_ERROR:
                errorMessage = "设备ID错误";
                break;

            case FA_TOKEN_ERROR:
                errorMessage = "设备token错误";
                break;

            case FA_DATA_ERROR:
                errorMessage = "数据库中无记录";
                break;

            case FA_PHONENUM_NOT_EXIST:
                errorMessage = "电话号码不存在";
                break;

            case FA_DEVICECONNECT_ERROR:
                errorMessage = "设备无连接";
                break;

            case FA_BIND_ERROR:
                errorMessage = "SN码错误";
                break;

            case FA_BIND_ERROR_INVITATION:
                errorMessage = "邀请码错误";
                break;

            case FA_BINDING_ALREADY:
                errorMessage = "已经绑定";
                break;

            case MESSAGE:
                errorMessage = "普通消息";
                break;

            case BIND_MESSAGE:
                errorMessage = "绑定消息";
                break;

            case FA_DATA_FORMATE_ERROR:
                errorMessage = "数据格式错误";
                break;

            case SAFEAREA_MESSAGE:
                errorMessage = "安全围栏消息";
                break;

            case FA_RIGHT_ERROR:
                errorMessage = "无权限";
                break;

            case BATTERY_MESSAGE:
                errorMessage = "电量消息";
                break;

            case UNBIND_ONLY_ONE_ERROR:
                errorMessage = "解绑定人为唯一管理员,请提升另一人为管理员后再解绑定";
                break;

            case UNBIND_DELETE_ERROR:
                errorMessage = "解绑孩子仍然绑定手表,请先解绑孩子的手表后,再解绑定孩子";
                break;

            default:
                errorMessage = "未知错误";

                LogUtil.e("err", "没有对应的code!!!!!");

                break;

        }
        return errorMessage;

    }

}
